package org.eclipse.mylyn.rememberthemilk.core;


import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;

public class RTMCorePlugin extends Plugin {



	// The plug-in ID
	public static final String PLUGIN_ID = "org.eclipse.mylyn.rememberthemilk.core";

	// The shared instance
	private static RTMCorePlugin plugin;

	public static final String ENCODING_UTF_8 = "UTF-8";

	public final static String REPOSITORY_KIND = "RememberTheMilk";

	private RTMRepositoryConnector connector;

	public RTMCorePlugin() {

	}

	@Override
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
	}

	@Override
	public void stop(BundleContext context) throws Exception {
		if (connector != null) {
			connector.stop();
			connector = null;
		}
		plugin = null;
		super.stop(context);
	}

	public RTMRepositoryConnector getConnector() {
		return connector;
	}

	void setConnector(RTMRepositoryConnector connector) {
		this.connector = connector;
	}

	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static RTMCorePlugin getDefault() {
		return plugin;
	}

	/**
	 * Returns the path to the file caching repository attributes.
	 */
	protected IPath getRepostioryAttributeCachePath() {
		IPath stateLocation = Platform.getStateLocation(RTMCorePlugin.getDefault().getBundle());
		IPath cacheFile = stateLocation.append("repositoryConfigurations");
		return cacheFile;
	}

}
